package cn.cloudpower.huabao.view;



import cn.cloudpower.huabao.activity.LoginActivity;
import cn.cloudpower.huabao.activity.R;
import cn.cloudpower.huabao.activity.Turntest;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.GridView;

public class MyGridView extends GridView {

	private Bitmap background;

	public MyGridView(Context context, AttributeSet attrs) {
		super(context, attrs);
		background = BitmapFactory.decodeResource(getResources(),
				R.drawable.bookshelf_layer_center);
	}

	@Override
	protected void dispatchDraw(Canvas canvas) {
		int count = getChildCount();
		int top = count > 0 ? getChildAt(0).getTop() : 0;
		int backgroundWidth = background.getWidth();
		int backgroundHeight = background.getHeight()+10;
		int width = getWidth();
		int height = getHeight();
		Log.i("width", width+"");
		for (int y = top; y < height; y += backgroundHeight) {
				Rect src = new Rect(100, 30, 300 ,300);
				Rect dst = new Rect(0, y, LoginActivity.windowWidth,y+backgroundHeight);
				canvas.drawBitmap(background, null,dst, null);
		}

		super.dispatchDraw(canvas);
	}

}
